package com.sany.assess.utils;

import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;

/**
 * @author lf_feng
 * @date 2020年12月7日
 */
public class DateFormatUtil {

    public static String InstantFormat(Instant transferTime) {
        String strDateFormat = "yyyy-MM-dd";
        Date strDate = InstantToDate(transferTime);
        SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
        String strFormat = sdf.format(strDate);
        return strFormat;
    }

    public static Date InstantToDate(Instant instant) {
        try {
            return new Date(instant.toEpochMilli());
        } catch (ArithmeticException ex) {
            throw new IllegalArgumentException(ex);
        }
    }

}